# 带哑元线性回归 数据已经有哑元变量
import pandas as pd
import scipy.stats as st
import matplotlib.pyplot as plt
import os
import numpy as np
import statsmodels.api as sm
data = np.genfromtxt('data4.txt', delimiter="\t")   # 在data4.txt中已经处理了哑元
print(data)
y = data[:, [1]]
x = data[:, 2:]


print(x)
x = sm.add_constant(x)
model = sm.OLS(y, x).fit()

print(model.summary())
print(model.mse_model)



